package com.noble.glamour.bean.center.user.light;

import android.os.Parcel;
import android.os.Parcelable;

import com.noble.library.base.bean.BaseData;

import org.json.JSONObject;

/**
 * 轻量用户资料
 */
public class UserLight extends BaseData implements Parcelable {
    private String nickname;
    private String avatar;
    private int vipStatus;

    private long uid;       //  自己id
    private long UidTo;  // 对方id

    private int statusFriend;    // 好友状态 1：已成为好友  0: 没有记录， -1：申请成为好友  -2：聊过的人  -3：已拒绝  -4：黑名单  -5： 删除

    @Override
    public void parseJson(String jsonStr) {
        JSONObject jsonObject = getJsonObject(jsonStr);

        this.setUid(jsonObject.optLong("Uid"));
        this.setAvatar(jsonObject.optString("Avatar"));
        this.setNickname(jsonObject.optString("NickName"));
        this.setUidTo(jsonObject.optInt("UidTo"));
        this.setStatusFriend(jsonObject.optInt("StatusFriend"));
        this.setVipStatus(jsonObject.optInt("IsVip"));
    }

    public boolean isVip() {
        return vipStatus == 1 || vipStatus == 2;
    }

    public int getVipStatus() {
        return vipStatus;
    }

    public void setVipStatus(int vipStatus) {
        this.vipStatus = vipStatus;
    }

    public long getUidTo() {
        return UidTo;
    }

    public void setUidTo(long UidTo) {
        this.UidTo = UidTo;
    }

    public long getUid() {
        return uid;
    }

    public void setUid(long uid) {
        this.uid = uid;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public int getStatusFriend() {
        return statusFriend;
    }

    public void setStatusFriend(int statusFriend) {
        this.statusFriend = statusFriend;
    }

    public UserLight() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.nickname);
        dest.writeString(this.avatar);
        dest.writeInt(this.vipStatus);
        dest.writeLong(this.uid);
        dest.writeLong(this.UidTo);
        dest.writeInt(this.statusFriend);
    }

    protected UserLight(Parcel in) {
        this.nickname = in.readString();
        this.avatar = in.readString();
        this.vipStatus = in.readInt();
        this.uid = in.readLong();
        this.UidTo = in.readLong();
        this.statusFriend = in.readInt();
    }

    public static final Creator<UserLight> CREATOR = new Creator<UserLight>() {
        @Override
        public UserLight createFromParcel(Parcel source) {
            return new UserLight(source);
        }

        @Override
        public UserLight[] newArray(int size) {
            return new UserLight[size];
        }
    };
}
